<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
        <meta charset="UTF-8">
    <link rel="stylesheet" href="${initParam.root}css/table.css" type="text/css">
<script type="text/javascript">
	$(document).ready(pageload);
			function pageload() {
				$("#History").change(
						function() {
							var category = $("#History").val();
							var history = $(this).val();
							if (category == "----------") {
								alert("정렬방식을 선택하세요.");
								return false;
							}
							$.ajax({
								type : "post",
								url : "find_DealByHistory.do",
								data : "history=" + history,
								success : function(list) {
									var view = "";
									$("#historyView").empty();
									$.each(list, function(index, data) {
										view += "<tr><td>" + data.dealNumber
												+ "</td><td>" + data.dealTitle
												+ "</td><td>" + data.customerId
												+ "</td><td>" + data.cartCount
												+ "</td><td>" + data.dealPrice
												+ "</td></tr>";
									});
									
									$("#historyView").html(view);
								}
							});//ajax
						});
			}
</script>
<c:choose>
	<c:when test="${requestScope.list=='Empty'}">
		<h2>상품이 없습니다.</h2>
	</c:when>
	<c:otherwise>
	<div align="center">
		<h2>판매 기록 리스트</h2>
	</div>
		<table border="1" class="registerMemberTable"  style="margin: 0 auto ; width: 500px" >
		<caption>
		<select id="History">
			<option value="----------">정렬선택</option>
			<option value="dealNumber">딜 번호</option>
			<option value="dealTitle">딜 명</option>
			<option value="customerId">구매자ID</option>
		</select>
		</caption>
			
				<tr>
					<th class="dealNumber">딜번호</th>
					<th class="dealTitle">딜명</th>
					<th class="customerId">구매자</th>
					<th class="dealCount">수량</th>
					<th class="dealPrice">가격</th>
				</tr>
				<tbody id="historyView">
			<c:forEach var="list" items="${requestScope.list}">
				<tr>
					<td>${list.dealNumber}</td>
					<td>${list.dealTitle}</td>
					<td>${list.customerId }</td>
					<td>${list.cartCount }</td>
					<td>${list.dealPrice }</td>
				</tr>
			</c:forEach>
				</tbody>
		</table>
	</c:otherwise>
</c:choose>